package com.fivetiger.service.impl;


import com.fivetiger.dao.DietDao;
import com.fivetiger.dao.TrainingDao;
import com.fivetiger.entity.Diet;
import com.fivetiger.entity.Training;
import com.fivetiger.service.inte.DietService;
import com.fivetiger.service.inte.TrainingService;
import com.fivetiger.util.RUtil;
import com.fivetiger.vo.PageBean;
import com.fivetiger.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.security.auth.Subject;
import java.util.List;

/**
 * @date 2021/6/20 - 17:02
 */
@Service
public class DietServiceImpl implements DietService {
    @Autowired
    private DietDao dao;

    //新增
    @Override
    public R save(Diet diet) {
        if(dao.insert(diet)>0){
            //成功
            return RUtil.ok();
        }else {
            //失败
            return RUtil.fail();
        }
    }

    //查询
    @Override
    public PageBean queryList() {
        List<Diet> list=dao.selectAll();
        return new PageBean(0,"",list.size(),list);
    }

    @Override
    public R change(Diet diet) {
        if(dao.update(diet)>0){
            return RUtil.ok();
        }else {
            return RUtil.fail();
        }
    }



}
